/* ---------------------------------------------------------------------------------------------
 *
 *            Capital Alliance Software Confidential Proprietary
 *            (c) Copyright CAS 201{x}, All Rights Reserved
 *                          www.pekall.com
 *
 * ----------------------------------------------------------------------------------------------
 */
package com.elvis.music.adapter;

import android.content.Context;
import android.database.Cursor;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.elvis.music.R;

public class MyPlayListItemAdapter extends BaseAdapter {
    
    private Context mContext;
    
    private Cursor mCursor;
    
    //private List<Music> listMusic;
    
    public  MyPlayListItemAdapter(Context context,Cursor cursor){
        mContext = context;
        mCursor = cursor;
        //listMusic = MusicApplication.getInstance().getListMusic();
    }

    public int getCount() {
        return mCursor.getCount();
    }

    public Object getItem(int position) {
        return null;
    }

    public long getItemId(int position) {
        return 0;
    }
    private TextView lineItemDuration;

    private TextView lineItemName;

    private TextView lineItemDescription;
    
    public View getView(int position, View convertView, ViewGroup parent) {
        mCursor.moveToPosition(position);
        if(convertView==null){
            convertView = LayoutInflater.from(mContext).inflate(R.layout.lineitem, null);
        }
        lineItemDuration = (TextView) convertView.findViewById(R.id.LineItemDuration);
        lineItemName = (TextView) convertView.findViewById(R.id.LineItemName);
        lineItemDescription = (TextView) convertView.findViewById(R.id.LineItemDescription);
        
        lineItemDuration.setText(mCursor.getString(3));
        lineItemDescription.setText(mCursor.getString(4));
        lineItemName.setText(String.valueOf(position+1)+"、"+mCursor.getString(2).substring(mCursor.getString(2).lastIndexOf("/")+1));
        return convertView;
    }

}
